package com.wmyg.antifake.entity;

import lombok.Data;
import org.hibernate.annotations.NotFound;
import org.hibernate.annotations.NotFoundAction;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import javax.persistence.*;
import java.util.Date;

/**
 * @author 王卓逸
 * @program TODO
 * @description TODO
 * @create 2019-05-05
 */
@Entity
@EntityListeners(AuditingEntityListener.class)
@Data
@Table(name = "bk_order")
public class Order {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "order_id")
    private Integer orderId;

    @OneToOne(cascade = {CascadeType.PERSIST, CascadeType.REFRESH})
    @JoinColumn(name = "record_id")
    private Record record;

//    @ManyToOne(cascade = {CascadeType.PERSIST, CascadeType.REFRESH})
//    @NotFound(action = NotFoundAction.IGNORE)
//    @JoinColumn(name = "user_id")
//    private BkUser user;
    @ManyToOne(cascade = {CascadeType.PERSIST, CascadeType.REFRESH})
    @NotFound(action = NotFoundAction.IGNORE)
    @JoinColumn(name = "company_id")
    private Company company;

    @ManyToOne(cascade = {CascadeType.PERSIST, CascadeType.REFRESH})
    @NotFound(action = NotFoundAction.IGNORE)
    @JoinColumn(name = "address_id")
    private UserAddress userAddress;

    @Column(name = "price")
    private Integer price;

    @Column(name = "print_type")
    private String printType;

    @Column(name = "order_state")
    private Integer orderState = 0; //0.未付款 1.微信预 2.支付宝预 3.均预 4.支付成功 5.印刷中 6.已发货 7.已完成 8。已关闭

    @Column(name = "wxpay_id")
    private String wxpayId;

    @Column(name = "alipay_id")
    private String alipayId;

    @Column(name = "wxpay_code_url")
    private String wxpayCodeUrl;

    @Column(name = "alipay_code_url")
    private String alipayCodeUrl;

    @Column(name = "wxpay_prepay_id")
    private String wxpayPrepayId;

    @Column(name = "mail_num")
    private String mailNum;

    @Column(name = "mail_company")
    private String mailCompany;

    @CreatedDate
    @Column(name = "create_time")
    private Date createTime;

    @LastModifiedDate
    @Column(name = "modify_time")
    private Date modifyTime;

}
